package org.hismig.test.migration;

import junit.framework.TestCase;

import org.hismig.cfg.Configuration;
import org.hismig.migration.Constructor;
import org.hismig.migration.Context;
import org.hismig.migration.parambuilder.IParamBuilder;
import org.hismig.migration.parambuilder.ParamBuildException;

/**
 * @declare: //TODO <br />
 *           This class created by Vansion.Hopihit on 2012-07-04 <br />
 *           <a href="mailto:vansionhopihit@gmail.com">Contact Me</a>
 * @version 1.0
 * @author Vansion.Hopihit
 * 
 */
public class ParamBuilderTester extends TestCase {

	private Constructor constructor;

	@Override
	protected void setUp() throws Exception {
		constructor = new Constructor();
		Configuration configuration = new Configuration(ConstructorTester.class
				.getResource("HisMig.cfg.xml").toURI());

		constructor.init(configuration);
	}

	public void testNetureDayBuilder() throws ParamBuildException {

		// assume it on the first DBExecutor's first parambuilder

		Context context = new Context();

		for (IParamBuilder paramBuilder : constructor.getDbExecutors().get(0)
				.getParamBuilders()) {
			paramBuilder.paramBuild(context);
		}
		assertNotNull(context.get("day1"));
		assertNotNull(context.get("day2"));
		assertNotNull(context.get("day3"));

		// today
		assertEquals("20120720", context.get("day1"));
		assertEquals("20120719", context.get("day2"));
		assertEquals("20120721", context.get("day3"));

	}

}
